using System;
using System.Collections.Generic;

public class GGScheduler : BehaviourSingleton<GGScheduler>
{
	public delegate void ActionTrigger();

	public class ScheduleListener
	{
		public DateTime triggerTime;

		public ActionTrigger actionTrigger;
	}

	private List<ScheduleListener> listeners = new List<ScheduleListener>();

	public void AddListener(ActionTrigger actionTrigger, DateTime triggerTime)
	{
		ScheduleListener scheduleListener = new ScheduleListener();
		scheduleListener.triggerTime = triggerTime;
		scheduleListener.actionTrigger = actionTrigger;
		listeners.Add(scheduleListener);
	}

	private void Update()
	{
		for (int num = listeners.Count - 1; num >= 0; num--)
		{
			if (DateTime.Now >= listeners[num].triggerTime)
			{
				listeners[num].actionTrigger();
				listeners.RemoveAt(num);
			}
		}
	}
}
